//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "Parabolic.h"
using namespace Cephei::QL::Math::Interpolations;
#include <gen/QL/Math/Interpolations/CubicInterpolation.h>
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::Interpolations::CParabolic::CParabolic (boost::shared_ptr<QuantLib::Parabolic>& childNative, Object^ owner) : CCubicInterpolation(CParabolic::typeid)
{
#ifdef HANDLE
	_phParabolic = NULL;
#endif
	_ppParabolic = &childNative;
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppParabolic));
}
Cephei::QL::Math::Interpolations::CParabolic::CParabolic (QuantLib::Parabolic& childNative, Object^ owner) : CCubicInterpolation(CParabolic::typeid)
{
#ifdef HANDLE
	_phParabolic = NULL;
#endif
	_ppParabolic = new boost::shared_ptr<QuantLib::Parabolic> (&childNative);
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppParabolic));
    _ParabolicOwner = owner;
    _CubicInterpolationOwner = owner;
}

Cephei::QL::Math::Interpolations::CParabolic::CParabolic (CParabolic^ copy) : CCubicInterpolation(CParabolic::typeid)
{
#ifdef HANDLE
	_phParabolic = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppParabolic = new boost::shared_ptr<QuantLib::Parabolic> (copy->GetShared());
        _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppParabolic));
    }
}
Cephei::QL::Math::Interpolations::CParabolic::CParabolic (PLATFORM::Type^ t) : CCubicInterpolation(CParabolic::typeid)
{
#ifdef HANDLE
	_phParabolic = NULL;
#endif
	if (!t->IsSubclassOf(CParabolic::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::Interpolations::CParabolic::CParabolic (QuantLib::Handle<QuantLib::Parabolic>& childNative, Object^ owner)  : CCubicInterpolation(CParabolic::typeid)
{
	_phParabolic = &childNative;
	_ppParabolic = &static_cast<boost::shared_ptr<QuantLib::Parabolic>>(childNative.currentLink());
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppParabolic));
    _ParabolicOwner = owner;
}
Cephei::QL::Math::Interpolations::CParabolic::CParabolic (QuantLib::Handle<QuantLib::Parabolic> childNative)  : CCubicInterpolation(CParabolic::typeid)
{
	_phParabolic = &childNative;
	_ppParabolic = &static_cast<boost::shared_ptr<QuantLib::Parabolic>>(childNative.currentLink());
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppParabolic));
}
#endif
#ifdef STRUCT
Cephei::QL::Math::Interpolations::CParabolic::CParabolic (QuantLib::Parabolic childNative)  : CCubicInterpolation(CParabolic::typeid)
{
#ifdef HANDLE
	_phParabolic = NULL;
#endif
	_ppParabolic = new boost::shared_ptr<QuantLib::Parabolic> (new QuantLib::Parabolic (childNative));
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppParabolic));
}
#endif

Cephei::QL::Math::Interpolations::CParabolic::~CParabolic ()
{
    if (_ppParabolic != NULL)
    {
	    delete _ppParabolic;
        _ppParabolic = NULL;
    }
}
Cephei::QL::Math::Interpolations::CParabolic::!CParabolic ()
{
    if (_ppParabolic != NULL)
    {
	    delete _ppParabolic;
    }
}
QuantLib::Parabolic& Cephei::QL::Math::Interpolations::CParabolic::GetReference ()
{
    if (_ppParabolic == NULL) throw REFNEW NativeNullException ();
	return **_ppParabolic;
}
boost::shared_ptr<QuantLib::Parabolic>& Cephei::QL::Math::Interpolations::CParabolic::GetShared ()
{
    if (_ppParabolic == NULL) throw REFNEW NativeNullException ();
	return *_ppParabolic;
}
QuantLib::Parabolic* Cephei::QL::Math::Interpolations::CParabolic::GetPointer ()
{
    if (_ppParabolic == NULL) throw REFNEW NativeNullException ();
	return &**_ppParabolic;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::Parabolic>& Cephei::QL::Math::Interpolations::CParabolic::GetHandle ()
{
	if (_phParabolic == NULL)
	{
		_phParabolic = new Handle<QuantLib::Parabolic> (*_ppParabolic);
	}
	return *_phParabolic;
}
#endif
bool Cephei::QL::Math::Interpolations::CParabolic::HasNative () 
{
	return (_ppParabolic != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

